namespace Belmost4PDA.Logic
{
    public class GlobalStates
    {

        public static GlobalStates __instance = null;
        private int idbr = -1;
        public event OnChangeHandle OnChange = null;
        /// <summary>
        /// Gets or sets the IDBR. On seting occures event OnChange
        /// </summary>
        /// <value>The IDBR.</value>
        public static int IDBR
        {
            get 
            {
                GlobalStates _instance = GetGlobalStates();
                return _instance.idbr; 
            }
            set
            {
                GlobalStates _instance = GetGlobalStates();
                _instance.idbr = value;
                _instance.StateChanges();
            }
        }

        /// <summary>
        /// Returns the global states instance.
        /// </summary>
        /// <returns></returns>
        //private GlobalStates()
        //{
            
        //}
        public static GlobalStates GetGlobalStates()
        {
            if(__instance==null)
            {
                //lock (typeof(GlobalStates))
              //  {
                    __instance = new GlobalStates();
                //}
            }
            return __instance;
        }
        /// <summary>
        /// Returns if ths bridge was chosen.
        /// </summary>
        /// <returns></returns>
        virtual public bool BridgeWasChosen()
        {
            if (idbr >= 0)
                return true;
            else
                return false;
        }

        /// <summary>
        /// Starts the event OnChanage
        /// </summary>
        public void StateChanges()
        {
            if(OnChange!=null)
                OnChange.Invoke();
        }
        public delegate void OnChangeHandle();
    }
}